import 'package:learning/bean/question_entity.dart';
import 'package:learning/bean/result_entity.dart';
import 'package:learning/uitls/Request.dart';

class QuestionService {
  static Future<QuestionEntity> getExamList(
      int langId, int subject, int category) async {
    var ddd = [];
    QuestionEntity listData = new QuestionEntity();
    ResultEntity data = await Request.get(
        "question/findByExamList?langId=$langId&subject=$subject&category=$category");
    if (data.success) {
      var ddd = data.data;
      print(ddd);

      QuestionEntity category = QuestionEntity.fromJson(ddd);
      return category;
    } else {
      throw Exception('Failed to load data');
    }
  }

  static Future<QuestionEntity> getExamLearnList(
      int langId, int subject, int category, int type) async {
    var ddd = [];
    QuestionEntity listData = new QuestionEntity();
    ResultEntity data = await Request.get(
        "question/findByLearnList?langId=$langId&subject=$subject&category=$category&type=$type");
    if (data.success) {
      var ddd = data.data;
      print(ddd);

      QuestionEntity category = QuestionEntity.fromJson(ddd);
      return category;
    } else {
      throw Exception('Failed to load data');
    }
  }

  static Future<ResultEntity> sendData(Map<String, dynamic> data) async {
    return Request.post("exam/edit", data);
  }
}
